home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 2
/
Nebula Two.iso
/
SourceCode
/
MiscKit1.7.1
/
MiscKitArchive.mbox
/
mbox
/
000198_misckit-reques…aska.et.byu.edu_Sat May 28 21:33:46 1994.msg
< prev
next >
Wrap
Internet Message Format
|
1994-10-30
|
7KB
Return-Path: <misckit-request@alaska.et.byu.edu>
Received: from alaska.et.byu.edu by darth.byu.edu (NX5.67d/NX3.0M)
id AA09205; Sat, 28 May 94 21:33:34 -0600
Received: from YVAX2.BYU.EDU by alaska.et.byu.edu; Sat, 28 May 1994 21:35:34 -0600
Received: from DIRECTORY-DAEMON by yvax.byu.edu (PMDF V4.3-8 #4169)
id <01HCVYG7P440019CN9@yvax.byu.edu>; 28 May 94 21:34:38 -0600 (MDT)
Received: from alaska.et.byu.edu by yvax.byu.edu (PMDF V4.3-8 #4169)
id <01HCVYG3BKTC0195EG@yvax.byu.edu>; Sat, 28 May 1994 21:34:32 -0600 (MDT)
Received: from yvax1.byu.edu by alaska.et.byu.edu; Sat,
28 May 1994 21:30:24 -0600
Received: from DIRECTORY-DAEMON by yvax.byu.edu (PMDF V4.3-8 #4169)
id <01HCVYA2M5DS9GV5LY@yvax.byu.edu>; Sat, 28 May 1994 21:29:41 MDT
Received: from fsa.cpsc.ucalgary.ca by yvax.byu.edu (PMDF V4.3-8 #4169)
id <01HCVY9YY1K002LPOD@yvax.byu.edu>; Sat, 28 May 1994 21:29:37 -0600 (MDT)
Received: from news.cpsc.ucalgary.ca (news.cpsc.ucalgary.ca [136.159.3.2])
by fsa.cpsc.ucalgary.ca (1.6) id <VAA02620@fsa.cpsc.ucalgary.ca>; Sat,
28 May 1994 21:28:50 -0600
Received: by news.cpsc.ucalgary.ca (1.2; from uucp@localhost)
id <VAA02581@news.cpsc.ucalgary.ca>; Sat, 28 May 1994 21:29:43 -0600
Received: from avocado.cuc.ab.ca by ajfcal.cuc.ab.ca (5.65c/Cuc2.2)
id AA06654; Sat, 28 May 1994 20:08:23 -0600
Received: by avocado.cuc.ab.ca id AA03245
(5.65c#3#/IDA-1.4.4 for misckit@byu.edu); Sat, 28 May 1994 21:01:13 -0600
Received: by NeXT.Mailer (1.100)
Received: by NeXT Mailer (1.100)
Date: Sat, 28 May 1994 21:01:13 -0600
From: "R. Todd Thomas" <todd@avocado.cuc.ab.ca>
Subject: Requesting input for file searching object design
To: misckit@byu.edu
Message-Id: <199405290301.AA03245@avocado.cuc.ab.ca>
Content-Transfer-Encoding: 7BIT
Hello Everyone,
Just looking for some input on the design of some classes for searching the filesystem. I have included the two interfaces that I've already come up with.
Here is what I have so far:
(FileSearch .h)
/***************************************************************************
* CLASS: FileSearch
* INHERITS FROM: Object
*
* Before creating this object, I tried to determine what kind of file
* searches one might want to do. Two came to mind: When you want to
* search for a specific file (find "image.tiff" in my ~/Icons directory)
* or searching for a list of files that meet some criteria (find me
* all files with the tiff extension).
*
* Searching for a specific file is done using the method
* -searchFor:inDirectory:recursive:followLinks: which will return the
* full pathname if the given filename is found.
*
* Searching for filenames that meet some criteria is done with
* -searchDirectory:recursive:followLinks:. For each filename that is in
* the given directory, the delegate is asked if it should be added to
* list. Therefore, the delegate could filter filenames by extension,
* date, owner, or anything else you might think of. If there is no
* delegate set, then everything will be added to the list.
*
*************************************************************************/
@interface FileSearch : Object
{
id delegate;
}
+ initialize;
- init;
- setDelegate: theDelegate;
- delegate;
// Methods for finding multiple filenames that match some criteria. The
// delegate is used to determine what should be added to the list. A list
// of MiscStrings is returned for all files that meet with the delegate's
// approval.
- (List *)searchDirectory: (const char *)directory;
- (List *)searchDirectory: (const char *)directory recursive:
(BOOL)recurse;
- (List *)searchDirectory: (const char *)directory recursive:
(BOOL)recurse
followLinks: (BOOL)followLinks;
// Methods for finding a single filename in a given directory. The
// delegate is not used. If the filename is found within the given
// directory, the full pathname is returned.
- (MiscString *)searchFor: (const char *)filename
inDirectory: (const char *)directory;
- (MiscString *)searchFor: (const char *)filename
inDirectory: (const char *)directory recursive:
(BOOL)recurse;
- (MiscString *)searchFor: (const char *)filename
inDirectory: (const char *)directory recursive:
(BOOL)recurse
followLinks: (BOOL)followLinks;
// Delegate cover method
- (BOOL)_addFile: (const char *)filename
fromDirectory: (const char *)directory;
// Archiving
- read: (NXTypedStream *)stream;
- write: (NXTypedStream *)stream;
@end
@interface Object (FileSearchDelegate)
// Implemented by the delegate to determine which filenames make it onto
// the list. Every file that is encountered in the directory stream is
// sent to the delegate to see if it should be included in the returned
// list of filenames. For instance, you could only include files with a
// tiff extension.Return YES to be added to the list and NO if it
// shouldn't.
- (BOOL)addFile: (const char *)filename fromDirectory: (const char *)directory;
@end
(DirectorySearch.h)
/*************************************************************************
* CLASS: DirectorySearch
* INHERITS FROM: FileSearch
*
* This class extends the functionality of FileSearch by allowing you
* to keep a list of directories that should be searched. I thought this
* would be useful when doing things like finding all .mybundle in various
* directories (~/Library, /LocalLibrary, /Library, etc).
*
*************************************************************************/
@interface DirectorySearch : FileSearch
{
id searchList; // a list of the directory paths to search
}
+ initialize;
- init;
- free;
// Methods to manipulate and access the search list
- (BOOL)addPathToSearchList: (const char *)fullPath;
- (BOOL)removePathFromSearchList: (const char *)fullPath;
- (BOOL)pathExistsInList: (const char *)fullPath;
- clearSearchList;
- searchList;
// Methods for searching for multiple filenames.
// The delegate still acts as the "filter" to return specific files.
- (List *)searchListForFiles;
- (List *)searchListForFilesWithRecursion: (BOOL)recurse;
- (List *)searchListForFilesWithRecursion: (BOOL)recurse
followLinks: (BOOL)followLinks;
// Methods for specific filename searches. It returns the fullpath if
// found. The delegate is not used.
- (MiscString *)searchListForFilename: (const char *)filename;
- (MiscString *)searchListForFilename: (const char *)filename
recursive: (BOOL)recurse;
- (MiscString *)searchListForFilename: (const char *)filename
recursive: (BOOL)recurse followLinks: (BOOL)followLinks;
// Archiving methods
- read: (NXTypedStream *)stream;
- write: (NXTypedStream *)stream;
@end
If anyone is interested in more information, or the information above is not clear enough, drop me a note.
Any alternate designs, criticisms, etc, are definitely welcome. Would anyone find classes like the above useful?
Oh, and for those that care, my next project is to fix up the MiscDragView, MiscImageView, and MiscIconWell classes.
Todd Thomas
todd@avocado.cuc.ab.ca [NeXTMail]